<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Roma::Client::Sender [ROMA documents]</title>
  <meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;

    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }

  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )

  // ]]>
  </script>

</head>
<body>


    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Roma::Client::Sender</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>


                <a href="../../../files/lib/roma/client/sender_rb.html">

                lib/roma/client/sender.rb

                </a>


        <br />

            </td>
        </tr>


        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>

                Object

            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">

  <div id="contextContent">

   </div>


    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">

        <a href="#M000001">new</a>&nbsp;&nbsp;

        <a href="#M000008">send_command</a>&nbsp;&nbsp;

        <a href="#M000002">send_route_mklhash_command</a>&nbsp;&nbsp;

        <a href="#M000003">send_routedump_command</a>&nbsp;&nbsp;

        <a href="#M000004">send_routedump_yaml_command</a>&nbsp;&nbsp;

        <a href="#M000005">send_stats_command</a>&nbsp;&nbsp;

        <a href="#M000007">send_verbosity_command</a>&nbsp;&nbsp;

        <a href="#M000006">send_version_command</a>&nbsp;&nbsp;

      </div>
    </div>

  </div>

    <!-- if includes -->

    <div id="section">




    <!-- if method_list -->

    <div id="methods">

      <h3 class="section-bar">Public Class methods</h3>


      <div id="method-M000001" class="method-detail">
        <a name="M000001"></a>

        <div class="method-heading">

          <a href="#M000001" class="method-signature">

          <span class="method-name">new</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000001-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 9</span>
 9:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
10:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <h3 class="section-bar">Public Instance methods</h3>


      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">

          <a href="#M000008" class="method-signature">

          <span class="method-name">send_command</span><span class="method-args">(nid, cmd, value = nil, receiver = :oneline_receiver)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
     <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 88</span>
 88:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_command</span>(<span class="ruby-identifier">nid</span>, <span class="ruby-identifier">cmd</span>, <span class="ruby-identifier">value</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">receiver</span> = <span class="ruby-identifier">:oneline_receiver</span>)
 89:         <span class="ruby-identifier">con</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">nid</span>)
 90:         <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">con</span>
 91:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>
 92:           <span class="ruby-identifier">con</span>.<span class="ruby-identifier">write</span> <span class="ruby-node">&quot;#{cmd}\r\n#{value}\r\n&quot;</span>
 93:         <span class="ruby-keyword kw">else</span>
 94:           <span class="ruby-identifier">con</span>.<span class="ruby-identifier">write</span> <span class="ruby-node">&quot;#{cmd}\r\n&quot;</span>
 95:         <span class="ruby-keyword kw">end</span>
 96:         <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">send</span>(<span class="ruby-identifier">receiver</span>, <span class="ruby-identifier">con</span>)
 97:         <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">nid</span>, <span class="ruby-identifier">con</span>)
 98:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ret</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>) <span class="ruby-operator">&amp;&amp;</span>
 99:             (<span class="ruby-identifier">ret</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^SERVER_ERROR/</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">ret</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^CLIENT_ERROR/</span>)
100:           <span class="ruby-identifier">raise</span> <span class="ruby-identifier">ret</span>
101:         <span class="ruby-keyword kw">end</span>
102:         <span class="ruby-identifier">ret</span>
103:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">

          <a href="#M000002" class="method-signature">

          <span class="method-name">send_route_mklhash_command</span><span class="method-args">(node_id)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 12</span>
12:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_route_mklhash_command</span>(<span class="ruby-identifier">node_id</span>)
13:         <span class="ruby-identifier">timeout</span>(<span class="ruby-value">1</span>){
14:           <span class="ruby-identifier">conn</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">node_id</span>)
15:           <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;mklhash 0\r\n&quot;</span>
16:           <span class="ruby-identifier">ret</span> = <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">gets</span>
17:           <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">node_id</span>, <span class="ruby-identifier">conn</span>)
18:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">chomp!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ret</span>
19:         }
20:       <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span><span class="ruby-identifier">e</span>
21:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{node_id} #{e.inspect}&quot;</span>
22:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
23:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000003" class="method-detail">
        <a name="M000003"></a>

        <div class="method-heading">

          <a href="#M000003" class="method-signature">

          <span class="method-name">send_routedump_command</span><span class="method-args">(node_id)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000003-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 25</span>
25:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_routedump_command</span>(<span class="ruby-identifier">node_id</span>)
26:         <span class="ruby-identifier">timeout</span>(<span class="ruby-value">1</span>){
27:           <span class="ruby-identifier">buf</span> = <span class="ruby-constant">RUBY_VERSION</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>)
28:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">buf</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">buf</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">8</span>
29:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">send_routedump_yaml_command</span>(<span class="ruby-identifier">node_id</span>)
30:           <span class="ruby-keyword kw">end</span>
31:           <span class="ruby-identifier">conn</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">node_id</span>)
32:           <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;routingdump\r\n&quot;</span>
33:           <span class="ruby-identifier">routes_length</span> = <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">to_i</span>
34:           <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">routes_length</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0</span>)
35:             <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">close</span>
36:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">:error</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">routes_length</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
37:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
38:           <span class="ruby-keyword kw">end</span>
39:           
40:           <span class="ruby-identifier">routes</span> = <span class="ruby-value str">''</span>
41:           <span class="ruby-keyword kw">while</span> (<span class="ruby-identifier">routes</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">routes_length</span>)
42:             <span class="ruby-identifier">routes</span> = <span class="ruby-identifier">routes</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">routes_length</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">routes</span>.<span class="ruby-identifier">length</span>)
43:           <span class="ruby-keyword kw">end</span>
44:           <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span>) <span class="ruby-comment cmt"># &quot;\r\n&quot;</span>
45:           <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">gets</span>
46:           <span class="ruby-identifier">rd</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">routes</span>)
47:           <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">node_id</span>, <span class="ruby-identifier">conn</span>)
48:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rd</span>
49:         }
50:       <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span><span class="ruby-identifier">e</span>
51:         <span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{node_id} #{e.inspect}&quot;</span>
52:         <span class="ruby-keyword kw">nil</span>
53:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000004" class="method-detail">
        <a name="M000004"></a>

        <div class="method-heading">

          <a href="#M000004" class="method-signature">

          <span class="method-name">send_routedump_yaml_command</span><span class="method-args">(node_id)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000004-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 55</span>
55:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_routedump_yaml_command</span>(<span class="ruby-identifier">node_id</span>)
56:         <span class="ruby-identifier">conn</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">node_id</span>)
57:         <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">write</span> <span class="ruby-value str">&quot;routingdump yaml\r\n&quot;</span>
58:         
59:         <span class="ruby-identifier">yaml</span> = <span class="ruby-value str">''</span>
60:         <span class="ruby-keyword kw">while</span>( (<span class="ruby-identifier">line</span> = <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">gets</span>) <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;END\r\n&quot;</span> )
61:           <span class="ruby-identifier">yaml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>
62:         <span class="ruby-keyword kw">end</span>
63: 
64:         <span class="ruby-identifier">rd</span> = <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">yaml</span>)
65:         <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">node_id</span>, <span class="ruby-identifier">conn</span>)
66:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rd</span>        
67:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000005" class="method-detail">
        <a name="M000005"></a>

        <div class="method-heading">

          <a href="#M000005" class="method-signature">

          <span class="method-name">send_stats_command</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000005-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 69</span>
69:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_stats_command</span>
70:         <span class="ruby-comment cmt"># TODO</span>
71:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">

          <a href="#M000007" class="method-signature">

          <span class="method-name">send_verbosity_command</span><span class="method-args">(ap)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 82</span>
82:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_verbosity_command</span>(<span class="ruby-identifier">ap</span>)
83:         <span class="ruby-identifier">conn</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">ap</span>)
84:         <span class="ruby-comment cmt"># TODO</span>
85:         <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">ap</span>, <span class="ruby-identifier">conn</span>)
86:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">

          <a href="#M000006" class="method-signature">

          <span class="method-name">send_version_command</span><span class="method-args">(ap)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/sender.rb, line 73</span>
73:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_version_command</span>(<span class="ruby-identifier">ap</span>)
74:         <span class="ruby-identifier">conn</span> = <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">get_connection</span>(<span class="ruby-identifier">ap</span>)
75:         <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">write</span>(<span class="ruby-value str">&quot;version\r\n&quot;</span>)
76:         <span class="ruby-identifier">res</span> = <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">gets</span>.<span class="ruby-identifier">chomp</span>
77:         <span class="ruby-constant">Roma</span><span class="ruby-operator">::</span><span class="ruby-constant">Messaging</span><span class="ruby-operator">::</span><span class="ruby-constant">ConPool</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">return_connection</span>(<span class="ruby-identifier">ap</span>, <span class="ruby-identifier">conn</span>)
78:         <span class="ruby-identifier">raise</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
79:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
80:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>



    </div>




  </div>

<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>
